package com.dailyblue.project.estate.controller;

import com.dailyblue.project.estate.commons.bean.Complaint;
import com.dailyblue.project.estate.commons.util.JsonResult;
import com.dailyblue.project.estate.service.ComplaintService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

/**
 * @Auther:Liu
 * @Testname:ComplaintController
 * @Date:2025/9/18 15:16
 */
@RestController
@RequestMapping("/complaint")
public class ComplaintController {
    @Resource
    private ComplaintService complaintService;

    @PostMapping
    JsonResult saveComplaint(Complaint complaint) {
        return complaintService.SaveComplaint(complaint);
    }

    @GetMapping("/{id}")
    JsonResult findOne(@PathVariable("id") String id) {
        return complaintService.findOne(id);
    }

    @GetMapping
    JsonResult findAll() {
        return complaintService.findAllComplaint();
    }

    @DeleteMapping("/{id}")
    JsonResult deleteOne(@PathVariable("id") String id) {
        return complaintService.deleteComplaint(id);
    }

    @PutMapping
    JsonResult updateOne(@RequestBody Complaint complaint) {
        return complaintService.updateComplaint(complaint);
    }
}
